import tkinter as tk
import random
import threading
import time
import os  

def show_warm_tip(window_list):
    window = tk.Tk()
    screen_width = window.winfo_screenwidth()
    screen_height = window.winfo_screenheight()
    window_width = 250
    window_height = 100
    x = random.randrange(0, screen_width - window_width)
    y = random.randrange(0, screen_height - window_height)
    window.title('温馨提示')
    window.geometry(f"{window_width}x{window_height}+{x}+{y}")
    tips = [
        '多喝水哦~', '保持微笑呀', '每天都要元气满满',
        '记得吃水果', '保持好心情', '好好爱自己', '生日快乐',
        '梦想成真', '期待下一次见面', '发大财',
        '顺顺利利', '早点休息', '愿所有烦恼都消失',
        '别熬夜', '天天开心', '天冷了，多穿衣服'
    ]
    tip = random.choice(tips)
    bg_colors = [
        'lightpink', 'skyblue', 'lightgreen', 'lavender',
        'lightyellow', 'plum', 'coral', 'bisque', 'aquamarine',
        'mistyrose', 'honeydew', 'lavenderblush', 'oldlace'
    ]
    bg = random.choice(bg_colors)
    label = tk.Label(
        window,
        text=tip,
        bg=bg,
        font=('微软雅黑', 16),
        width=30,
        height=3
    )
    label.pack()
    def close_window():
        window.destroy()
    close_btn = tk.Button(window, text='关闭', font=('微软雅黑', 12), command=close_window)
    close_btn.pack(pady=5)
    window.attributes('-topmost', True)
    window_list.append(window)
    window.mainloop()

def auto_stop(duration=10):
    time.sleep(duration)

    os._exit(0)

if __name__ == "__main__":
    window_list = []
    threads = []

    stop_thread = threading.Thread(target=auto_stop, args=(16,))
    stop_thread.daemon = True
    stop_thread.start()

    for i in range(110):
        t = threading.Thread(target=show_warm_tip, args=(window_list,))
        threads.append(t)
        time.sleep(0.001)
        threads[i].start()